<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="basePath" value="${pageContext.request.contextPath}" scope="application"/>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="${basePath}/static/css/bootstrap.css">
    <link rel="stylesheet" href="${basePath}/static/css/common.css">
    <link rel="stylesheet" href="${basePath}/static/css/style.css">
    <script src="${basePath}/static/js/bootstrap.js"></script>
    <script src="${basePath}/static/bower_components/jquery/dist/jquery.js"></script>
</head>
<body class="index_bg">
<div class="container">
    <div class="content">
        <h2>登录</h2>
        <div class="input_group input-group-up box">
            <div class="img_control"><img src="${basePath}/static/images/login_yymc.png"></div>
            <input type="text" class="flex1" placeholder="用户名" id="username">
        </div>
        <div class="input_group input-group-down box">
            <div class="img_control"><img src="${basePath}/static/images/login_mm.png"></div>
            <input type="text" class="flex1" placeholder="密码">
        </div>
        <div class="box mt10">
            <div class="input_control flex1">
                <input type="checkbox" id="rmbpwd">
                <label>记住密码</label>
            </div>
            <a href="#" class="forget">忘记密码</a>
        </div>
        <a href="#" class="btn disabled" id="submit">登录</a>
    </div>
</div>
</body>
</html>
<script>
    $(document).ready(function () {
        if ($.cookie("rmbUser") == "true") {
            $("#ck_rmbUser").attr("checked", true);
            $("#username").val($.cookie("username"));
            $("#password").val($.cookie("password"));
        }
        $("#submit").keyup(function () {
//        var txt=$("input").val();
            var username = $("#username").val();
            var pwd = $("#password").val();
            if ($("#rmbpwd").is(":checked")) {
                save();
            }
            $.post("xxx.action", {username: username, password: pwd}, function (result) {
//            $("span").html(result);
                if (result.success) {
                    window.location.href = './B/index.html';
                } else {
                    alert(result.error);
                }
            });
        });

    });
    //记住用户名密码
    function Save() {
        if ($("#ck_rmbUser").attr("checked")) {
            var str_username = $("#username").val();
            var str_password = $("#password").val();
            $.cookie("rmbUser", "true", {expires: 7}); //存储一个带7天期限的cookie
            $.cookie("username", str_username, {expires: 7});
            $.cookie("password", str_password, {expires: 7});
        }
        else {
            $.cookie("rmbUser", "false", {expire: -1});
            $.cookie("username", "", {expires: -1});
            $.cookie("password", "", {expires: -1});
        }
    };
</script>